package com.example.myapplication;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity21 extends AppCompatActivity {

    public MainActivity21() {
        super();
    }

    TextView textView;

    Button button;

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("zyy","21:onStart");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d("zyy","21:onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("zyy","21:onDestroy");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("zyy","21:onResume");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d("zyy","21:onRestart");
    }

    @SuppressLint({"SetTextI18n", "MissingInflatedId"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout21);

        Log.d("zyy","21:onCreate"); //logcat调试用

        Intent intent=getIntent();

        button=findViewById(R.id.button3);

//        String name=intent.getStringExtra("name");
//
//        int age=intent.getIntExtra("age",20);

        Bundle bundle=intent.getExtras();

        assert bundle != null;
        String name=bundle.getString("name");

        int age=bundle.getInt("age");

        textView=findViewById(R.id.textView4);

        textView.setText("name："+name+"  "+"age："+age);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent1=new Intent(MainActivity21.this,MainActivity2.class);
                intent1.putExtra("result","sss");
                setResult(666,intent1);


                finish();
            }
        });
    }
}